package algotithm.weekendrace.leetcode226.test1;

/**
 * @author zhouyanxiang
 * @Date 2021-01-2021/1/31-10:16
 * @Title 5654. 盒子中小球的最大数量
 */
public class Solution {

    public static void main(String[] args) {
        Solution solution = new Solution();
        int lowLimit = 1, highLimit =10;
        int i = solution.countBalls(lowLimit, highLimit);
        System.out.println(i);
    }

    public int countBalls(int lowLimit, int highLimit) {
        int res = Integer.MIN_VALUE;
        int[] arr = new int[100010];
        int[] num = new int[100010];
        for (int i = lowLimit; i <= highLimit; i++) {
            num[i] = i;
        }
        for (int j = lowLimit; j <= highLimit; j++) {
            int x = 0;
            int s = 0;
            while (num[j] > 0) {
                 s = num[j] % 10;
                 num[j] /= 10;
                 x += s;
             }
             arr[x] += 1;
        }
        for (int i = 0; i < arr.length; i++) {
            res = Math.max(arr[i], res);
        }
        return res;
    }

}
